Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Defining a class
Classes encapsulate state and behavior. Defining a class requires a mechanism to define the set of data members that represent the class's state and a set of related methods that provide the behavior of the class. The data members and methods of a class constitute a data type. As with other data types, the compiler verifies that references to a class are consistent with its type. Another type of class is an interface, which provides a means to enforce a consistent implementation for similar class types. Class-based objects are running instances of classes. At run time there can be many instances of a class, each with its own set of data values. There can also be many object references that point to a single object instance.
A class definition begins with a
CLASSstatement that specifies the type defined by the class. A class also requires a distinct compilable file type for defining classes. A class file type has a.clsfilename extension, and the filename must match the class name defined in theCLASSstatement. This class name is the final component of the class type name, which begins with a platform-independent specification of the class file path relative to thePROPATH. All references to a class are done through this type name.Only one class can be defined per source file. However as with procedures, you can use include files to extend the definition of a class beyond a single source code file. The compiled version of a class file is an r-code file that has the
.rextension, the same as for procedures. Classes are always publicly scoped and therefore are available to all other classes and procedures within an application. Classes are not accessible across an application server boundary.A user-defined class is composed of multiple types of elements. It contains data members which define the state of the class. It can also contain methods and other elements that define the behavior of a class, as follows:
- An optional constructor, which is a method that is invoked when the class is instantiated.
- An optional destructor, which is a method that is invoked when the object is destroyed.
- Methods to define additional behavior of the class.
ONstatements to define 4GL widget events for a class.- User-defined function prototypes to specify how and where to call user-defined functions accessed from methods or
ONstatements in the class.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |